from moviepy import VideoFileClip
from moviepy.video.fx import MirrorX,MirrorY ,TimeMirror,FadeIn,FadeOut,Loop
clip = VideoFileClip("video.mp4")
MirrorX(clip).write_videofile("video_mirror_x.mp4") # 水平翻转
MirrorY(clip).write_videofile("video_mirror_y.mp4") # 垂直翻转

clip.rotate(180).write_videofile("video_rotate.mp4") # 旋转180度
clip.crop(0, 100, 400, 400).write_videofile("video_crop.mp4") # 裁剪
clip.resize(0.5).write_videofile("video_resize.mp4") # 缩放
clip.speedx(2).write_videofile("video_speedx.mp4") # 加速播放
clip.speedx(0.5).write_videofile("video_speedx_slow.mp4") # 减速播放
clip.subclip(0, 5).write_videofile("video_subclip.mp4") # 提取子视频
clip.set_fps(30).write_videofile("video_set_fps.mp4") # 设置帧率
clip.set_audio(clip.audio.set_fps(44100)).write_videofile("video_set_audio_fps.mp4") # 设置音频帧率
clip.set_audio(clip.audio.set_duration(10)).write_videofile("video_set_audio_duration.mp4") # 设置音频时长
clip.set_audio(clip.audio.set_volume(0.5)).write_videofile("video_set_audio_volume.mp4") # 设置音频音量
clip.set_audio(clip.audio.set_audio_codec("aac")).write_videofile("video_set_audio_codec.mp4") # 设置音频编码
clip.set_audio(clip.audio.set_audio_bitrate(192000)).write_videofile("video_set_audio_bitrate.mp4") # 设置音频比特率
clip.set_audio(clip.audio.set_audio_channels(2)).write_videofile("video_set_audio_channels.mp4") # 设置音频声道数
clip.set_audio(clip.audio.set_audio_sample_size(16)).write_videofile("video_set_audio_sample_size.mp4") # 设置音频采样大小
clip.set_audio(clip.audio.set_audio_codec("aac")).write_videofile("video_set_audio_codec.mp4") # 设置音频编码
clip.set_audio(clip.audio.set_audio_bitrate(192000)).write_videofile("video_set_audio_bitrate.mp4") # 设置音频比特率
clip.set_audio(clip.audio.set_audio_channels(2)).write_videofile("video_set_audio_channels.mp4") # 设置音频声道数
clip.set_audio(clip.audio.set_audio_sample_size(16)).write_videofile("video_set_audio_sample_size.mp4") # 设置音频采样大小
clip.set_audio(clip.audio.set_audio_codec("aac")).write_videofile("video_set_audio_codec.mp4") # 设置音频编码
clip.set_audio(clip.audio.set_audio_bitrate(192000)).write_videofile("video_set_audio_bitrate.mp4") # 设置音频比特率
clip.set_audio(clip.audio.set_audio_channels(2)).write_videofile("video_set_audio_channels.mp4") # 设置音频声道数
clip.set_audio(clip.audio.set_audio_sample_size(16)).write_videofile("video_set_audio_sample_size.mp4") # 设置音频采样大小
clip.margin(10).write_videofile("video_margin.mp4") # 添加边框
TimeMirror(clip).write_videofile("video_time_mirror.mp4") # 倒放视频
FadeIn(clip, duration=1).write_videofile("video_fade_in.mp4") # 淡入效果
FadeOut(clip, duration=1).write_videofile("video_fade_out.mp4") # 淡出效果
Loop(clip, n=2).write_videofile("video_loop.mp4") # 循环播放
